﻿namespace NopControls
{
    public struct HSV
    {
        readonly double hue;
        readonly double saturation;
        readonly double value;

        public HSV(double hue, double saturation, double value)
        {
            this.hue = hue;
            this.saturation = saturation;
            this.value = value;
        }

        public double Hue
        {
            get { return hue; }
        }

        public double Saturation
        {
            get { return saturation; }
        }

        public double Value
        {
            get { return value; }
        }

        public static bool operator == (HSV h1, HSV h2)
        {
            return (h1.Hue == h2.Hue && h1.Saturation == h2.Saturation && h1.Value == h2.Value);
        }

        public static bool operator != (HSV h1, HSV h2)
        {
            return !(h1 == h2);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                int result = hue.GetHashCode();
                result = (result * 397) ^ saturation.GetHashCode();
                result = (result * 397) ^ value.GetHashCode();
                return result;
            }
        }

        public bool Equals(HSV other)
        {
            return other.hue.Equals(hue) && other.saturation.Equals(saturation) && other.value.Equals(value);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) 
                return false;
            return obj.GetType() == typeof (HSV) && Equals((HSV) obj);
        }
    }
}
